home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / LSSYNC.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  72 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)lssync.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10.  
  11. /* library headers */
  12. #include <blkio.h>
  13.  
  14. /* local headers */
  15. #include "lseq_.h"
  16.  
  17. /*man---------------------------------------------------------------------------
  18. NAME
  19.      lssync - lseq synchronize
  20.  
  21. SYNOPSIS
  22.      #include <lseq.h>
  23.  
  24.      int lssync(lsp);
  25.      lseq_t *lsp;
  26.  
  27. DESCRIPTION
  28.      The lssync function causes any buffered data for the named lseq
  29.      to be written to the file.  The lseq remains open and the buffer
  30.      contents remain intact.
  31.  
  32.      lssync will fail if one or more of the following is true:
  33.  
  34.      [EINVAL]       lsp is not a valid lseq pointer.
  35.      [LSENOPEN]     lsp is not open.
  36.  
  37. SEE ALSO
  38.      lsclose, lslock, lssetbuf, lssetvbuf.
  39.  
  40. DIAGNOSTICS
  41.      Upon successful completion, a value of 0 is returned.  Otherwise,
  42.      a value of -1 is returned, and errno set to indicate the error.
  43.  
  44. ------------------------------------------------------------------------------*/
  45. #ifdef AC_PROTO
  46. int lssync(lseq_t *lsp)
  47. #else
  48. int lssync(lsp)
  49. lseq_t *lsp;
  50. #endif
  51. {
  52.     /* validate arguments */
  53.     if (!ls_valid(lsp)) {
  54.         errno = EINVAL;
  55.         return -1;
  56.     }
  57.  
  58.     /* check if not open */
  59.     if (!(lsp->flags & LSOPEN)) {
  60.         errno = LSENOPEN;
  61.         return -1;
  62.     }
  63.  
  64.     /* synchronize file with buffers */
  65.     if (bsync(lsp->bp) == -1) {
  66.         LSEPRINT;
  67.         return -1;
  68.     }
  69.  
  70.     return 0;
  71. }
  72.